package com.jye.rseven.user.serivce.impl;

import org.springframework.stereotype.Service;
import com.jye.rseven.domain.Advertise;
import com.jye.rseven.service.AdvertiseService;
import com.jye.rseven.user.mapper.AdvertiseMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Service
public class AdvertiseServiceImpl implements AdvertiseService {

    @Autowired
    AdvertiseMapper advertiseMapper;

    @Override
    public List<Advertise> findAllAd() {
        List<Advertise> advertiseList = advertiseMapper.findAllAd();
        return advertiseList;
    }

    @Override
    public List<Advertise> findAdByType(String type) {
        List<Integer> aIds = advertiseMapper.findAIdsByType(type);
        List<Advertise> advertiseList = new ArrayList<>();
        Advertise advertise;
        for (Integer aId : aIds) {
            advertise = advertiseMapper.findAdById(aId);
            advertiseList.add(advertise);
        }
        return advertiseList;
    }
}
